package serializable;

import serializable.BaseBean;
import sun.rmi.runtime.Log;

import javax.swing.text.View;
import java.io.*;

public class TestBean extends BaseBean implements Serializable {
    public String desc;
    public static final int serialVersionUID = 1;
    public TestBean(String id) {
        super(id);
    }

    @Override
    public String toString() {
        return "TestBean{" +
                "desc='" + desc + '\'' +
                ", property1='" + property1 + '\'' +
                ", property2='" + property2 + '\'' +
                '}';
    }

    public void deserialization(View view) {
        ObjectInputStream objectInputStream = null;
        try {
            objectInputStream = new ObjectInputStream(new FileInputStream("aaatest.txt"));
            TestBean testBean = (TestBean) objectInputStream.readObject();
//            Log.i(TAG,"deserialization"+testBean.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
//        try {
//
//            TestBean testBean = new TestBean("");
//            testBean.property1 = "属性88999988";
//            testBean.property2 = "属性88999988";
//            testBean.desc = "我是testbean88999988";
//
//            ObjectOutputStream objectOutputStream = new ObjectOutputStream(new FileOutputStream("aaatest.txt"));
//            objectOutputStream.writeObject(testBean);
//        } catch (IOException e) {
//            e.printStackTrace();
//        }

        ObjectInputStream objectInputStream = null;
        try {
            objectInputStream = new ObjectInputStream(new FileInputStream("aaatest.txt"));
            TestBean testBean = (TestBean) objectInputStream.readObject();
            System.out.println("反序列化结果："+testBean.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
